#define DEBUG
#include <cstdio>

using namespace std;

typedef long long ll;

const int maxn=10000;

ll fact[2*maxn+1], unfact[2*maxn+1];

ll qpower(ll a, int n, int mods) {
  ll s=1;
  for (; n>1; n>>=1) {
    if (n&1) {
      s = s*a%mods;
    }
    a = a*a%mods;
  }
  return s*a%mods;
}

void getPrime(int prime[], int n) {
  static bool book[maxn+1];

  for (int i=2; i<=n; i++) {
    if (!book[i]) {
      prime[++prime[0]] = i;
    }
    for (int j=i*2; j<=n; j+=i) {
      book[j] = true;
    }
  }
}

int main() {
  freopen("exercise.in", "r", stdin);
  freopen("exercise.out", "w", stdout);

  static int prime[maxn+1];
  int n, m;
  scanf("%d %d", &n, &m);
  getPrime(prime, n);

  static ll f[maxn+1];
  f[0] = 1;
  for (int i=1; i<=prime[0]; i++) {
		for (int j=n; j>0; j--) {
			for (int k=prime[i]; k<=j; k*=prime[i]) {
				f[j] = (f[j-k]*k%m+f[j])%m;
			}
		}
  }

  ll ans=0;
  for (int i=0; i<=n; i++) {
    ans = (ans+f[i])%m;
  }
  printf("%lld", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
